#include <stdio.h>
void mage(int *data,int low,int mid,int height){
    int b[100];
    int k,i,j;
    
    for(k=low;k<=height;k++){
        b[k]=data[k];
    }
    for(i=low,j=mid+1,k=low;i<=mid&&j<=height;k++){
        if(b[i]<b[j]){
            data[k]=b[i++];
        }
        else{
            data[k]=b[j++];
        }
    }
    while (i<=mid)
    {
        data[k++]=b[i++];
    }
    while (j<=height)
    {
        data[k++]=b[j++];
    }
    
}
void mergesort(int *data,int low,int height){
    if(low<height){
        
        int mid=(low+height)/2;
        mergesort(data,low,mid);
        mergesort(data,mid+1,height);
        mage(data,low,mid,height);
    }
}